import time
from selenium.webdriver.common.by import By
class Fund:
    def fund_money(self, driver, username, password, paypwd):
        # sql_select = "select * from user where username = %s"
        # param_select = [username]
        # select (sql_select, param_select)
        # if len(select(sql_select, param_select)) == 0:
        #     sql_insert = "insert into user(id,username,password,paypwd) values(%s,%s,%s,%s)"
        #     param_insert = [id,username, password, paypwd]
        #     select(sql_insert, param_insert)
        #     sql_insert = "insert into bankcard(cardBank,type,cardNum,userId,balance) values(%s,%s,%s,%s,%s)"
        #     param_insert = [cardBank,type,cardNum,userId,balance]
        #     select(sql_insert, param_insert)
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        driver.find_element(By.XPATH,
                                  '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button').click()
        driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[2]/input').send_keys(paypwd)
        driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[3]/a[1]').click()
    def fund_money_1(self,driver,username,password,paypwd):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        driver.find_element(By.XPATH,
                            '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button').click()
        driver.find_element(By.XPATH,
                            '/html/body/div[3]/div[2]/input').send_keys(paypwd)
        driver.find_element(By.XPATH,
                            '/html/body/div[3]/div[3]/a[1]').click()
        elem = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div').text
        return elem
    def fund_time(self, driver,username,password,paypwd):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a').click()
        driver.find_element(By.XPATH,
                                  '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button').click()
        driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[2]/input').send_keys(paypwd)
        driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[3]/a[1]').click()
    def fund_time_1(self, driver,username,password,paypwd):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a').click()
        driver.find_element(By.XPATH,
                                  '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button').click()
        driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[2]/input').send_keys(paypwd)
        driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[3]/a[1]').click()
        elem = driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div').text

        return elem
    def fund_stock(self, driver,username,password,paypwd):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a').click()
        driver.find_element(By.XPATH,'/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button').click()
        driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/input').send_keys(paypwd)
        driver.find_element(By.XPATH,'/html/body/div[3]/div[3]/a[1]').click()
    def fund_stock_1(self, driver,username,password,paypwd):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a').click()
        driver.find_element(By.XPATH,
                            '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button').click()
        driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/input').send_keys(paypwd)
        driver.find_element(By.XPATH, '/html/body/div[3]/div[3]/a[1]').click()
        elem = driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div').text
        return elem
    def fund_card_add(self, driver,username,password):
        #到达新增银行卡
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[4]/a').click()
        driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[4]/ul/li[3]/a').click()
    def fund_card_add1(self, driver,cardname,cardnum):
        driver.find_element(By.XPATH, '//*[@id="bankCard_add_modal_btn"]').click()
        time.sleep(2)
        driver.find_element(By.XPATH,
                                    '/html/body/div[1]/div/main/div/div/div[4]/div/div/div[2]/form/div[1]/div[1]/input').send_keys(cardname)
        driver.find_element(By.XPATH,
                                    '/html/body/div[1]/div/main/div/div/div[4]/div/div/div[2]/form/div[3]/div[1]/input').send_keys(cardnum)
        driver.find_element(By.XPATH, '/html/body/div[1]/div/main/div/div/div[4]/div/div/div[3]/button[2]').click()
        driver.refresh()
        time.sleep(2)
    def fund_card_add2(self, driver,cardname1,cardnum1):
        driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div[3]/div/button').click()
        time.sleep(2)
        driver.find_element(By.XPATH,
                                    '/html/body/div[1]/div/main/div/div/div[4]/div/div/div[2]/form/div[1]/div[1]/input').send_keys(cardname1)
        driver.find_element(By.XPATH,
                                    '/html/body/div[1]/div/main/div/div/div[4]/div/div/div[2]/form/div[3]/div[1]/input').send_keys(cardnum1)
        driver.find_element(By.XPATH, '/html/body/div[1]/div/main/div/div/div[4]/div/div/div[3]/button[2]').click()
        driver.refresh()
        time.sleep(2)
    def fund_card_add3(self, driver,cardname2,cardnum2):
        driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div[4]/div/button').click()
        time.sleep(2)
        driver.find_element(By.XPATH,
                                    '/html/body/div[1]/div/main/div/div/div[5]/div/div/div[2]/form/div[1]/div[1]/input').send_keys(cardname2)
        driver.find_element(By.XPATH,
                                    '/html/body/div[1]/div/main/div/div/div[5]/div/div/div[2]/form/div[3]/div[1]/input').send_keys(cardnum2)
        driver.find_element(By.XPATH, '/html/body/div[1]/div/main/div/div/div[5]/div/div/div[3]/button[2]').click()
        driver.refresh()
        time.sleep(2)
















